<template>
  <tbody>
    <tr v-for="(item,index) in List" :key="index">
      <td>
        <input type="checkbox" v-model="item.checked" />
      </td>
      <td>{{ item.name }}</td>
      <td>{{ item.price }}</td>
      <td>
        <button @click="down(index)">-</button>{{ item.num
        }}<button @click="up(index)">+</button>
      </td>
      <td>{{item.num * item.price }}</td>
      <td><button @click="del(index)">删除</button></td>
    </tr>
  </tbody>
</template>

<script>
export default {
  props: {
    List: {
      type: Array,
      required: true,
    },
  },
  methods:{
    del(index){
      this.List.splice(index,1)
    },
    down(index){
      if(this.List[index].num>=1){
        this.List[index].num-=1
      }
     
    },
    up(index){
      this.List[index].num+=1
    },
  }
}
</script>

<style scoped></style>
